function [ ] = plotAbatementBids( obj, plant_ids, filename, inlogs )
% plotEmissionsVsHeat Compare emissions to aggregate heat output
%
% INPUTS:
%   obj : etsModel object
if nargin < 4
    inlogs = false;
end

%% Formatting options
textProp = {'fontsize'    , 14, ...
            'FontName'    , 'Times New Roman'};
labProp  = {'fontsize'    , 14, ...
            'FontName'    , textProp{4}};

%% Select data to plot

bids = obj.bid( ismember(obj.bid.id_plant,plant_ids), ...
                  {'id_plant','bid_qE','bid_p'} );
              
if inlogs
    bids.bid_qE = log(bids.bid_qE);
    bids.bid_p  = log(bids.bid_p);
end

if inlogs
    addString = 'Log ';
else
    addString = '';
end          
        
%% Plot residual demand, own supply and market clearing
f0 = figure;
keep = (bids.id_plant == plant_ids(1));
h1 = scatter(bids(keep,:).bid_qE,bids(keep,:).bid_p,100);
hold on;

if length(plant_ids) > 1
    for i = 1:length(plant_ids)
        keep = (bids.id_plant == plant_ids(i));
        scatter(bids(keep,:).bid_qE,bids(keep,:).bid_p,100);
    end    
end


xlabel([addString 'Emissions (kg)'],textProp{:},'Interpreter','latex');
ylabel([addString 'Marginal abatement cost / bid price'],textProp{:},'Interpreter','latex');

title('Marginal abatement costs: plant level',textProp{:},'Interpreter','latex');

% Figure formatting
set(gcf, 'Color'       , 'w' );
set(gca, labProp{:}, ...
         'Box'         , 'off'              , ...
         'LineWidth'   , 1.5                , ...
         'PlotBoxAspectRatio', [1 0.75 0.75]);  

% 45-degree line
% h3 = plot([0,0],[pmin,pmax],'k-','LineWidth',1.5);

% Reset axis limits
xl = xlim;
xmax = xl(2);
xlim([ 0 xmax ]);

yl = ylim;
ymax = yl(2);
ylim([ 0 ymax ]);

hold off;

%% Export figure

% Crop whitespace 
fig = gcf;
fig.PaperPositionMode = 'auto';
fig_pos = fig.PaperPosition;
fig.PaperSize = [fig_pos(3) fig_pos(4)];

ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];

fprintf(1,'Writing %s to file ...\n',filename);
print(f0,'-dpdf','-painters','-noui','-r600',filename);
fprintf(1,' complete.\n');


end